package com.base.data.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.base.data.dao.AreaDao;
import com.base.data.entity.Area;
import com.mysteel.util.ObjectUtils;

@Service("areaService")
public class AreaServiceImpl implements AreaService
{
	@Autowired
	private AreaDao areaDao;
	
	@Override
	public void saveArea(Area area)
	{
		areaDao.add (area);
	}
	
	@Override
	public Area getAreaByName(String name)
	{
		return areaDao.getByName (name);
	}
	
	@Override
	public Area getAreaById(String id)
	{
		return areaDao.get (id);
	}
	
	@Override
	public List<Area> queryArea()
	{
		return areaDao.query ();
	}
	
	@Override
	public void updateArea(Area area)
	{
		Area a = areaDao.get (area.getId ());
		
		if (ObjectUtils.notNull (a))
		{
			a.setName (area.getName ());
			a.setdescription (area.getdescription ());
			areaDao.update (a);
		}
	}

	@Override
	public void deleteArea(String id)
	{
		areaDao.delete (id);
		
	}
	
}
